# -*- coding = utf-8 -*-
# @Time    : 2025/3/29 下午4:20
# @Author  : yqk
# @File    : study_selenium.py
# @Software: PyCharm
''''

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.options import Options

# 设置选项
options = Options()
options.add_argument('--disable-gpu')
options.add_argument('--no-sandbox')

# 自动管理ChromeDriver
service = Service(ChromeDriverManager().install())

# 创建浏览器实例
browser = webdriver.Chrome(service=service, options=options)

browser.maximize_window()
browser.get('https://www.baidu.com')

# print(browser.title)
# input("按回车键关闭浏览器...")
# browser.quit()

'''


from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options

service = Service(r'D:\python-code\chromedriver-win64\chromedriver.exe')

opt = Options()
opt.add_argument('--disable-blink-features=AutomationControlled')
browser = webdriver.Chrome(service=service, options=opt)
url = 'https://www.baidu.com'
url2 = 'https://www.jd.com/'
browser.get(url)
browser.get(url2)
browser.back()
browser.forward()
browser.refresh()
page_text = browser.page_source
print(page_text)
input('按回车键关闭')